/**
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 2010  Sean Beecroft

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

 * @version 1.10 2010-01-01
 * @author Sean Beecroft
 */
package yawiki.server.application;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Editor extends HttpServlet {

    public void doGet(HttpServletRequest request,
            HttpServletResponse response)
            throws IOException, ServletException {
        String page = request.getParameter("page");
        response.setContentType("application/x-java-jnlp-file");
        PrintWriter out = response.getWriter();

        out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?> ");
        out.println("<!-- JNLP File Application --> ");
        out.println("<jnlp ");
        out.println("  spec=\"1.0+\" ");
        out.println("  codebase=\"" + Globals.codeBase + "\" ");
        out.println("  href=\"launch.jnlp\"> ");
        out.println("  <information> ");
        out.println("    <title>" + Globals.title + "</title> ");
        out.println("    <vendor>yawiki.org</vendor> ");
        out.println("    <homepage href=\"" + Globals.editorHomepage + "\"/> ");
        out.println("    <description>" + Globals.editorLongDescription + "</description> ");
        out.println("    <description kind=\"short\">" + Globals.editorShortDescription + "</description> ");
        out.println("    <icon href=\"" + Globals.icon + "\"/> ");
        out.println("    <icon kind=\"splash\" href=\"" + Globals.splash + "\"/>");
        out.println("    <offline-allowed/> ");
        out.println("  </information> ");
        out.println("  <security> ");
        out.println("      <all-permissions/>");
        out.println("  </security> ");
        out.println("  <resources> ");
        out.println("    <j2se version=\"1.4+\"/> ");
        out.println("    <jar href=\"" + Globals.signedJar + "\"/> ");
        out.println("    </resources> ");
        out.println("  <application-desc main-class=\"yawiki.XMLClient\"> ");
        out.println("  	<argument>" + page + "</argument>");
        out.println("  </application-desc> ");
        out.println("</jnlp> ");
        out.flush();
    }

    public void doPost(HttpServletRequest request,
            HttpServletResponse response)
            throws IOException, ServletException {
        doGet(request, response);
    }
}
